﻿using System.Collections.Generic;
using UnityEngine;
using ZYLFramework.Manage;
using ZYLFramework.UI;

namespace Game.UI
{
    public class OverPanelCtrl:UICtrl
    {
        public OverPanelView View;
        public OverPanelModel Model;
        public override void Init()
        {
            View = BaseView as OverPanelView;
            Model = BaseModel as OverPanelModel;
            
            View?.QuitBtn.onClick.AddListener(QuitGame);
            View?.RestartBtn.onClick.AddListener(RestartGame);
            
            SceneVariants.RegisterMessageEvent(EventEnum.SetOverWinText, SetText);
        }
        
        private void QuitGame()
        {
            Debug.Log("返回主菜单"); 
            UIManage.Instance.Close();
            EventManage.Instance.Notify(EventEnum.QuitGame);
        }
        
        private void RestartGame()
        {
            Debug.Log("重新开始游戏"); 
            UIManage.Instance.Close();
            EventManage.Instance.Notify(EventEnum.RestartGame);
        }

        public void SetText(object[] objects)
        {
            View.WinText.text = (string)objects[0];
        }
    }
}